function NPCDamaged( npc, hitgroup, dmginfo )
		local attacker = dmginfo:GetAttacker()
		local damagedone = dmginfo:GetDamage()
		
		--Turrets dont hurt powercores!
		if attacker:GetClass() == "npc_turret_floor" then
			if npc.GetClass(npc) == "inv_powercore" then
				dmginfo:ScaleDamage( 0 )
				return
			end
		end

		if attacker:IsPlayer() == true then
			dmginfo:SetDamage( dmginfo:GetDamage() * (attacker:GetWeaponDamage() / 100) )
		end
		
		if attacker:GetClass() == "npc_turret_floor" then
			if(attacker:GetOwner() == nil) then return end
			statman_AddPlayerXP(attacker:GetOwner(), damagedone * INV_WAVES[CurrentWave][INV_WAVE_POINTSPERDAMAGEDONE])
			attacker:GetOwner():AddMoney(damagedone * INV_WAVES[CurrentWave][INV_WAVE_MONEYPERDAMAGEDONE])
			attacker:GetOwner():AddFrags(damagedone)
		end
		
		if attacker:IsPlayer() == true then
			if npc.GetClass(npc) == "inv_powercore" then
				dmginfo:ScaleDamage( 0 )
			else
				-- You dont get points for shooting a turret
				if npc.GetClass(npc) != "npc_turret_floor" then
					statman_AddPlayerXP(attacker, damagedone * INV_WAVES[CurrentWave][INV_WAVE_POINTSPERDAMAGEDONE])
					attacker:AddMoney(damagedone * INV_WAVES[CurrentWave][INV_WAVE_MONEYPERDAMAGEDONE])
					attacker:AddFrags(damagedone)
				end
			end
			
		end
		
end
hook.Add("ScaleNPCDamage","inv_scalenpcdamage",NPCDamaged)

function statman_AddPlayerXP(playerto, xp)
	local currentXP = playerto:GetXP()
	local currentLevel = playerto:GetLevel()
	-- IS the player going to level up?
	if(currentXP + xp > INV_LEVELS[currentLevel + 1]) then
		-- yes, Let's level them up
		-- First calculate how much will be left after levelling up
		local leftover = (currentXP + xp) - (INV_LEVELS[currentLevel + 1])
		playerto:SetXP(leftover)
		playerto:SetLevel(currentLevel + 1)
		playerto:AddStatPoints(INV_POINTSPERLEVEL)
		playerto:AddMoney(INV_MONEYPERLEVEL)
		
		for _, ply in ipairs( player.GetAll() ) do
			SendMessageToPlayerChat(ply, playerto:GetName() .. " is now level " .. (currentLevel + 1))
		end
	else
		-- No, just give the XP
		playerto:AddXP(xp)
	end
	
end

